package com.xncoding.mybatisplus.ctr;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xncoding.mybatisplus.dto.FsOperationLogOutput;
import com.xncoding.mybatisplus.map.UserMapper;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

public class UserController {
    @Resource
    UserMapper userMapper;
    @GetMapping("t1")
    public void user(){
        IPage<FsOperationLogOutput> page = new Page<>(1, 10);
        List<String> newsTypes= Arrays.asList("1|2".split("|"));

        IPage<FsOperationLogOutput> page1 = userMapper.selectPage(page, new LambdaQueryWrapper<FsOperationLogOutput>()
                // 主要演示这里可以加条件。在name不为空的时候执行
                .eq(StringUtils.isNotEmpty("1"), FsOperationLogOutput::getUsrId, "%" + "1" + "%")
                .in(StringUtils.isNotEmpty("1"), FsOperationLogOutput::getUsrId,newsTypes)

        );

        System.out.println(JSON.toJSONString(page1));
    }

}
